import { SkillModelInfo } from "./info/SkillModelInfo";
import { PetSkillModelInfo } from "./info/PetSkillModelInfo";
import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
//class SkillModelConfig
    
    export  class SkillModelConfig
    {
        constructor()
        {
            
            this._map = new Map<any, any> /* flash.utils.Dictionary */();
            this._petMap = new Map<any, any> /* flash.utils.Dictionary */();
            if (SkillModelConfig._instance != null) 
            {
                throw new Error(" ResConfig 单例 ");
            }
            this.init();
            return;
        }

        /* internal  */write(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=arg1.skill;
            for(loc2 of loc4) 
            {
                loc1 = new SkillModelInfo();
                loc1.code = loc2.code;
                loc1.skillType = loc2.skillType;
                loc1.src = loc2.src;
                loc1.hit_point = loc2.hit_point;
                loc1.scale_x = loc2.scale_x;
                loc1.scale_y = loc2.scale_y;
                loc1.pos_x = loc2.pos_x;
                loc1.pos_y = loc2.pos_y;
                loc1.sound = loc2.sound;
                loc1.dir = loc2.dir;
                loc1.duration = loc2.duration;
                loc1.depth = loc2.depth;
                loc1.blend_mode = loc2.blend_mode;
                loc1.mode = loc2.mode;
                loc1.rotation = loc2.rotation;
                loc1.isThrow = loc2.isThrow;
                if (loc2.hasOwnProperty("isNeedShotAction")) 
                {
                    loc1.isNeedShotAction = loc2.isNeedShotAction;
                }
                if (loc2.hasOwnProperty("isCopy")) 
                {
                    loc1.isCopy = loc2.isCopy;
                }
                if (loc2.hasOwnProperty("param1")) 
                {
                    loc1.param1 = loc2.param1;
                }
                this._map[loc2.code] = loc1;
            }
            return;
        }

        /* internal  */writePet(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=arg1.skill;
            for(loc2 of loc4) 
            {
                loc1 = new PetSkillModelInfo();
                loc1.petModelId = loc2.code;
                loc1.skillType = loc2.skillType;
                loc1.src = loc2.src;
                loc1.hit_point = loc2.hit_point;
                loc1.scale_x = loc2.scale_x;
                loc1.scale_y = loc2.scale_y;
                loc1.pos_x = loc2.pos_x;
                loc1.pos_y = loc2.pos_y;
                loc1.sound = loc2.sound;
                loc1.dir = loc2.dir;
                loc1.duration = loc2.duration;
                loc1.depth = loc2.depth;
                loc1.blend_mode = loc2.blend_mode;
                loc1.mode = loc2.mode;
                loc1.rotation = loc2.rotation;
                loc1.isThrow = loc2.isThrow;
                this._petMap[loc2.code] = loc1;
            }
            return;
        }

        public init(): void
        {
            var loc1=ConfigManager.instance.getObjectByFileName("skillsModel.xml");
            var loc2=ConfigManager.instance.getObjectByFileName("petSkillsModel.xml");
            this.write(loc1);
            this.writePet(loc2);
            return;
        }

        public getSkillModelInfo(arg1: Object): SkillModelInfo
        {
            return this._map[arg1];
        }

        public getPetSkillModelInfo(arg1: Object): SkillModelInfo
        {
            return this._petMap[arg1];
        }

        public static get instance(): SkillModelConfig
        {
            if (SkillModelConfig._instance == null) 
            {
                SkillModelConfig._instance = new SkillModelConfig();
            }
            return SkillModelConfig._instance;
        }

        /* internal */ /* var */_map: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_petMap: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ static /* var */_instance: SkillModelConfig;
    }
